/**
 * ...
 * @author Franco Ponticelli
 */

package uform.ui.comp;
import uform.property.IProperty;
import uform.property.LimitedFloatPropertyDecorator;
import uform.property.Property;
import uform.ui.comp.Control;
import uform.ui.comp.Component;

class NumberControl extends Control<Float>
{
	public var min(default, null) : IProperty<Float>;
	public var max(default, null) : IProperty<Float>;
	public var minInclusive(default, null) : IProperty<Bool>;
	public var maxInclusive(default, null) : IProperty<Bool>;
	public var increment(default, null) : IProperty<Float>;
	
	public function new(name : String, ?value : Float)
	{
		super(name, value);
		// TODO: properties should support validators aswell
		var property = new LimitedFloatPropertyDecorator(this.value);
		this.value = property;
		var me = this;
		min = new Property();
		min.onChange.add(function() {
			property.min = me.min.get();
		});
		max = new Property();
		max.onChange.add(function() {
			property.max = me.max.get();
		});
		minInclusive = new Property();
		minInclusive.onChange.add(function() {
			property.minInclusive = me.minInclusive.get();
		});
		maxInclusive = new Property();
		maxInclusive.onChange.add(function() {
			property.maxInclusive = me.maxInclusive.get();
		});
		// TODO: link increment to value validation
		increment = new Property();
	}
}